package com.miyu.client1.controller.bookAdmin;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.miyu.client1.service.bookAdmin.bookAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据管理公共处理方法
 */

@RequestMapping("BookAdmin")
@RestController
public class bookAdmin {

    @Autowired
    private bookAdminService bas;

    /**
     * 书籍管理 书籍查询管理功能
     * @param jo
     * @return
     */
    @RequestMapping("/queryBookInfo")
    public JSONArray queryBookInfo(@RequestBody JSONObject jo){
        JSONObject ts = new JSONObject();
        JSONArray rs = bas.queryBookList(jo);
        return rs;
    }

    /**
     * 查询数据明细 和章节数据
     * @param param
     * @return
     */
    @RequestMapping("queryBookChapterList")
    public JSONObject queryBookChapterList(@RequestBody JSONObject param){
        return bas.queryBookChapterList(param);
    }

    /**
     * 阅读书籍
     * @param param
     * @return
     */
    @RequestMapping("readBookChapter")
    public JSONObject readBookChapter(@RequestBody JSONObject param){
        return  bas.readBookChapter(param);
    }

    /**
     * 查询单章节明细
     * @param param
     * @return
     */
    @RequestMapping("queryChapter")
    public JSONObject queryChapter(@RequestBody JSONObject param){
        return bas.queryChapter(param);
    }

    /**
     *
     */
    @RequestMapping("CheckRule")
    public JSONObject CheckRule(@RequestBody JSONObject param){

        return bas.CheckRule(param);
    }

    /**
     * 规则保存和修改
     * 对应章节 书籍列不可修改
     * @param param
     * @return
     */
    @RequestMapping("saveOrUpdateBookRuleSet")
    public JSONObject saveOrUpdateBookRuleSet(@RequestBody JSONObject param){
        return  bas.saveOrUpdateBookRuleSet(param);
    }

    /**
     * 规则查询
     * @param param
     * @return
     */
    @RequestMapping("queryRuleSet")
    public JSONArray queryRuleSet (@RequestBody JSONObject param){
        return bas.queryRuleSet(param);
    }

    @RequestMapping("deleteRuleSet")
    public  JSONObject deleteRuleSet(@RequestBody JSONArray param){
        return bas.deleteRuleSet(param);
    }

    /**
     * 小说章节数据初始化
     * @param param
     * @return
     */
    @RequestMapping("initData")
    public JSONObject initData (@RequestBody JSONObject param){
        return bas.initData(param);
    }

    /**
     * 初始化章节更新
     * @param param
     * @return
     */
    @RequestMapping("initDataChapter")
    public JSONObject initDataChapter(@RequestBody JSONObject param){
        return bas.initDataChapter(param);
    }
}
